package com.example.recyclerview_wechat_fuwu;


import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initview();
        in();
    }
    private  void initview(){
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        LinearLayoutManager lim = new LinearLayoutManager(this);
        lim.setOrientation(LinearLayoutManager.VERTICAL);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,4,RecyclerView.VERTICAL,false);
        recyclerView.setLayoutManager(gridLayoutManager);
        String[] strings = new String[]{"信用卡还款","微粒贷借钱","理财通","保险服务"};
        int[] ints = new int[]{R.drawable.fuwu_xinyongka,R.drawable.fuwu_weilidai,R.drawable.fuwu_licaitong,R.drawable.fuwu_baoxianfuwu};
        List<bean> data = new ArrayList<bean>();

        for (int i = 0; i < strings.length; i++) {
            bean b= new bean();
            b.setName(strings[i]);
            b.setImg(ints[i]);
            data.add(b);

        }
        MyAdapter adapter = new MyAdapter(this);
        adapter.setData(data);
        recyclerView.setAdapter(adapter);



    }
    private void in(){
        RecyclerView recyclerView1 = findViewById(R.id.recycler_view1);
        LinearLayoutManager lim1 = new LinearLayoutManager(this);
        lim1.setOrientation(LinearLayoutManager.VERTICAL);
        GridLayoutManager gridLayoutManager1 = new GridLayoutManager(this,4,RecyclerView.VERTICAL,false);
        recyclerView1.setLayoutManager(gridLayoutManager1);
        String[] strings1 = new String[]{"手机充值","生活缴费","Q币充值","城市服务","腾讯公益","医疗健康","防疫健康码"};
        int[] ints1 = new int[]{R.drawable.fuwu_shoujichongzhi,R.drawable.fuwu_shenghuojiaofei,R.drawable.fuwu_qbi,
                R.drawable.fuwu_chengshi,R.drawable.fuwu_gongyi,R.drawable.fuwu_yiliao,R.drawable.fuwu_jiankangma};

        List<bean> data1 = new ArrayList<bean>();

        for (int i = 0; i < strings1.length; i++) {
            bean b1= new bean();
            b1.setName(strings1[i]);
            b1.setImg(ints1[i]);
            data1.add(b1);

        }
        MyAdapter adapter1 = new MyAdapter(this);
        adapter1.setData(data1);
        recyclerView1.setAdapter(adapter1);
    }
}